Skip to content

Add regression test for long-range SvdCut with identity components - #551

Merged
lkdvos merged 1 commit into
mainfrom
issue550
Nov 2, 2026
Merged

lkdvos merged 1 commit into
mainfrom
issue550

Conversation

@lkdvos

@lkdvos lkdvos commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Closes #550.

The bug reported in #550 is already fixed on main by #539. This PR only adds the issue's reproducer as a regression test.

Cause (v0.14.0)

In v0.14.0, the identity component of C was projected out with an unnormalized identity: t = tr(1ᴴ C), without dividing by dim(P). The gauge transformation stays exact in exact arithmetic, but the identity component is never actually removed. The leftover t grows by roughly a factor of dim(P) per site along an interaction channel; for the MWE, the site waiting to absorb it reached norm(C) ≈ 4e11. The result is catastrophic cancellation that gets worse with interaction distance. Traceless operators have t = 0, so they were unaffected.

#539 rewrote the canonicalization as a QR of [1 C; 0 A] with the identity as its first column, which normalizes the projection correctly.

Max |⟨H⟩ - ⟨Hc⟩| for the MWE in #550 (n ⊗ n, trunctol(rtol = 0), 5 random states):

sites v0.14.0 main
(5, 6) 2e-15 2e-16
(5, 7) 4e-14 2e-16
(5, 25) 0.078 7e-16

Test

test/algorithms/changebonds.jl: the existing "SvdCut on long-range FiniteMPOHamiltonian" testset gains the reproducer from #550: n ⊗ n on sites (5, 25) of a 30-site ℂ^4 chain, compressed with SvdCut(; trunc = trunctol(; rtol = 0.0)), with the expectation value checked to rtol = 1e-10. The testset's other case only couples sites at most four apart, which v0.14.0 already handled correctly. On v0.14.0 the new case has a relative error of 5e-3 to 0.5; on main it is about 1e-15.

🤖 Generated with Claude Code

Compressing a FiniteMPOHamiltonian with a long-range interaction whose
operators have non-zero trace lost precision geometrically with distance
in v0.14.0 (#550). This was fixed by the canonical-form rewrite in #539;
this test guards against regressions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lkdvos
lkdvos merged commit e5b75cf into main Nov 2, 2026
27 of 28 checks passed
@lkdvos
lkdvos deleted the issue550 branch November 2, 2026 18:54
@lkdvos lkdvos mentioned this pull request Nov 2, 2026
lkdvos referenced this pull request Nov 2, 2026
* Update changelog for v0.14.1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Bump version to v0.14.1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Update CITATION.cff for v0.14.1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compressing Hamiltonians with certain long-range interactions loses precision

1 participant